package com.briup.jz.web.controller;
import com.briup.jz.bean.Platform;
import com.briup.jz.service.IPlatformService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("platform")
@Api(description="平台账户信息")
public class PlatformController {
    @Autowired
    private IPlatformService iPlatformService;
    @ApiOperation("查询平台账户信息")
    @GetMapping("/query")
    public Message query(Long id){
        List<Platform> platforms = iPlatformService.query(id);

        return MessageUtil.success(platforms);
    }
    @ApiOperation("新建或修改平台账户信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "balance",value = "费用率",paramType = "form"),
            @ApiImplicitParam(name = "bankCard",value = "银行卡号",paramType = "form")
    })
    @PostMapping("/saveorupdate")
    public Message saveOrUpdate(Platform platform){
        iPlatformService.saveOrUpdate(platform);
        return MessageUtil.success("操作成功");
    }
    @ApiOperation("删除平台账户信息")
    @GetMapping("/delete")
    public Message delete(Long id){
        iPlatformService.deleteById(id);
        return  MessageUtil.success("操作成功");
    }
}
